<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telphone=no, email=no"/>
	<meta name="description" content="">
	<meta name="keywords" content="">
	<title>环保数据管家-大气环境</title>
	<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
	<link rel="stylesheet" type="text/css" href="assets/css/iconfont/iconfont.css">
	<link rel="stylesheet" type="text/css" href="assets/css/app.css">
	<link rel="stylesheet" type="text/css" href="assets/css/label.css">
	<!-- <link rel="stylesheet" type="text/css" href="assets/css/air.css">
    <link rel="stylesheet" type="text/css" href="assets/css/map.css"> -->
	<style type="text/css">
	.zhibiao-legend .zb-item {
	    background-color:#FFF;
	    border-color: #57d7c6;
	}
    .zhibiao-legend .disable{
        background-color: #fcfcfc !important;
		border-color: #57d7c6 !important;
		color:#57d7c6 !important;
    }
	.highcharts-legend {display:none;}
	.order-hd-title a {text-decoration:none;color:#333333;}
	.aqi-tables tbody td.date small {line-height:normal;}
	#month-select,.month-select{
		outline: none;
		border: 1px solid #bbbec1;
		border-radius: 2px;
		background: none;
		color: #a1a7ad;
	}
	.order-bd tfoot td{
		font-size: 0.5rem;
		text-align: left;
		color: #666666;
	}
	i.targetNum{color: #666666!important;font-size:0.5rem!important;}
	#sorttable tr td{
		padding: 8px 0;
		font-size: 0.6rem;
	}
	.top-warp{
		text-shadow: none;
		background-size: 100% 100%;
	}
	.citys-order{
		margin: 0;
		padding: 0;
	}
	.citys-order div{
		border:1px solid #a3e9e0;
		padding: 0.5rem 0;
		border-top: 0;
		background: #fff;
	}
	.citys-order div:first-child{
		border-right: 0;
		border-left: 0;
	}
	.citys-order div:last-child{
		border-right: 0;
	}
	.citys-order b:first-child{
		color: #4c5e70;
		font-size: 0.8rem;
		padding: 0.15rem 0;
		float: left;
		margin-left: 0.6rem;
		font-weight: normal;
	}
	.citys-order b:last-child{
		border-radius: 20%/35%;
		float: right;
		margin-right: 0.6rem; 
		background-color: RGBA(62, 193, 114, 1.00);
		color: #ffffff;
		font-size: 0.8rem;
		width: 1.8rem;
		padding: 0.15rem 0;
		text-align: center;
	}
	.citys-order b.waring{
		background-color: RGBA(253, 195, 38, 1.00);
	}
	.infobox{
			width: 50%;
			margin:0.25rem auto;
			padding: 0.15rem;
			border-radius: 3px;
		}
	.aqi-note sub,#aqi-tables sub{
		vertical-align: sub;
	}
	</style>
	<script type="text/javascript">
	function appendZeroleft(str){
		return ('0'+str).substr(-2,2);
	}
		/**
   * 对Date的扩展，将 Date 转化为指定格式的String
   * 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用 1-2 个占位符
   * 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
   * eg:
   * (new Date()).pattern("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
   * (new Date()).pattern("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
   * (new Date()).pattern("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
   * (new Date()).pattern("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
   * (new Date()).pattern("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
   */
  Date.prototype.pattern = function(fmt) {
    var o = {
      "M+": this.getMonth() + 1, //月份
      "d+": this.getDate(), //日
      "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
      "H+": this.getHours(), //小时
      "m+": this.getMinutes(), //分appendZeroleft
      "s+": this.getSeconds(), //秒
      "q+": Math.floor((this.getMonth() + 3) / 3), //季度
      "S": this.getMilliseconds() //毫秒
    };
    var week = {
      "0": "\u65e5",
      "1": "\u4e00",
      "2": "\u4e8c",
      "3": "\u4e09",
      "4": "\u56db",
      "5": "\u4e94",
      "6": "\u516d"
    };
    if (/(y+)/.test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    if (/(E+)/.test(fmt)) {
      fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "星期" : "") : "") + week[this.getDay() + ""]);
    }
    for (var k in o) {
      if (new RegExp("(" + k + ")").test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
      }
    }
    return fmt;
  }
	</script>
</head>
<body>
	<header>
		<span id="app-back" class="app-back"><i class="iconfont icon-left"></i></span>
		<span class="title">环保数据管家</span>
	</header>
	<div class="pf-content">
		<div id="realtime-aqi" class="top-warp">
			<div class="left_cont">
				<p class="pb-title">空气质量指数</p>
				<p class="pb-tit-num" id="rt-aqi-num"></p> 	
				<p class="pb-tit-lv" id="rt-aqi-lv"></p>
			</div>
			<div class="right_cont">
				<div id="rt-aqi-weathernote"></div>
			</div>
		</div>

		<div class="nav_list">
			<ul id="nav_list">
				<li class="active">
					<a onclick="selectTag('tagContent0',this,'index')">
						<span class="water_pic water_monitoring"></span>
						<span>空气质量监测</span>
					</a>
				</li>
				<li >
					<a onclick="selectTag('tagContent1',this,'air')">
						<span class="water_pic water_analysis"></span>
						<span>空气质量分析</span>
					</a>
				</li>
				<li >
					<a onclick="selectTag('tagContent2',this,'map')">
						<span class="water_pic water_assessment"></span>
						<span>目标考核</span>
					</a>
				</li>
			</ul>
		</div>
		<div id=tagContent>
			<div class="loadding">
				<span><img src="assets/img/loadding.gif"></span>
			</div>
			<div class="tagContent active" id="tagContent0">
				<div class="chart-legend flex-row">
					<span data-idx="0" class="active flex-row-item aqi-chart-time">每小时</span>
					<span data-idx="1" class="flex-row-item aqi-chart-time">每天</span>
					<span data-idx="2" class="flex-row-item aqi-chart-time">每月</span>
				</div>
				<div class="zhibiao-legend flex-row">
				    <span class="flex-row-item zb-item color-aqi">AQI</span>
					<span class="disable flex-row-item zb-item color-pm25">PM2.5</span>
					<span class="disable flex-row-item zb-item color-so2">SO<sub>2</sub></span>
					<span class="disable flex-row-item zb-item color-no2">NO<sub>2</sub></span>
					<span class="disable flex-row-item zb-item color-pm10">PM10</span>
					<span class="disable flex-row-item zb-item color-co">CO</span>
					<span class="disable flex-row-item zb-item color-o3">O<sub>3</sub></span>
				</div>
				<div class="aqi-chart" id="aqi-chart"></div>
			
				<!-- 空气质量监测 -->
				<div class="aqi-tables">
					<h1 class="h_tit">空气质量预报</h1>
					<table>
						<tbody id="aqi-tables">
							<tr><td colspan="4">暂无预报信息</td></tr>
						</tbody>
						<tfoot>
							<tr>
								<td width="15%">时间</td>
								<td width="30%">AQI范围</td>
								<td width="30%">天气预报</td>
								<td width="30%">首要污染物</td>
							</tr>
						</tfoot>
					</table>
				</div>

				<div class="aqi-order">
					<h1 class="h_tit">空气质量实时排名</h1>
					<div id="citys-order1" class="citys-order flex-row">
						<div class="flex-row-item" id="app-order-link-js"><b>省内排名</b><b id="js-order-val"></b></div>
						<div class="flex-row-item" id="app-order-link-csj"><b>74城市排名</b><b id="csj-order-val"></b></div>
					</div>	
				</div>

				<div class="aqi-order2">
				    <div class="title_box">
				    	<h1 class="h_tit">空气质量月度排名</h1>
						<div class="order-hd-select">
							<select class="month-select" id=""><option value="201610">2016年10月</option></select>
						</div>
			        </div>
					<div id="citys-order2" class="citys-order flex-row">
						<div class="flex-row-item" id="app-74order-link-js"><b>省内排名</b><b id="citys74-js-order-val">9</b></div>
						<div class="flex-row-item" id="app-74order-link-all"><b>74城市排名</b><b id="citys74-all-order-val">24</b></div>
					</div>
				</div>
			</div>

			<!-- 空气质量分析 -->
			<div class="tagContent wuranwu-wrap" id="tagContent1">
				
				<!--空气质量天数比例-->
				<h1 class="h_tit">空气质量天数比例</h1>
				<div class="wr-chart-item" id="wrchat-airquality"></div>
				<!--污染物浓度比例饼图-->
				<div class="title_box">
			    	<h1 class="h_tit">年度首要污染物分析</h1>
					<div class="order-hd-select">
						<select class="month-select" id="everyyear-select"></select>
					</div>
		        </div>
		        <div class="wr-chat">
		        	<div class="wr-chat-item u-bd-bt" id="wrchat-eveyearbili"></div>
		        </div>
		        <div class="title_box">
			    	<h1 class="h_tit">月度首要污染物分析</h1>
					<div class="order-hd-select">
						<select class="month-select everymonth-select" id="everymonth-select-1"></select>
					</div>
		        </div>
		        <div class="wr-chat">
					<div class="wr-chat-item u-bd-bt" id="wrchat-evemonbili"></div>
				</div>
				<div class="title_box">
			    	<h1 class="h_tit">每月空气质量及污染物浓度比例</h1>
					<div class="order-hd-select">
						<select class="month-select everymonth-select" id="everymonth-select-2"></select>
					</div>
		        </div>
		        <div class="wr-chat">
		        	<div class="air-pie">
		        		<div class="wr-zhibiao-control flex-row bing">
							<span class="flex-row-item zhibiao-item color-aqi active" dn='aqi'>AQI</span>
							<span class="flex-row-item zhibiao-item color-pm25" dn='pm25'>PM<sub>2.5</sub></span>
							<span class="flex-row-item zhibiao-item color-pm10" dn='pm10'>PM<sub>10</sub></span>
							<span class="flex-row-item zhibiao-item color-so2" dn='so2'>SO<sub>2</sub></span>
							<span class="flex-row-item zhibiao-item color-no2" dn='no2'>NO<sub>2</sub></span>
							<span class="flex-row-item zhibiao-item color-co" dn='co'>CO</span>
							<span class="flex-row-item zhibiao-item color-o3" dn='o3'>O<sub>3</sub></span>
						</div>
						<div class="wr-chat-item" id="wrchat-zhibiao"></div>
		        	</div>
		        </div>
		        <div class="title_box">
			    	<h1 class="h_tit">时间段空气质量分析</h1>
					<div class="order-hd-select">
						<select class="month-select everymonth-select" id="onetime-select"></select>
					</div>
		        </div>
		        <div class="wr-chat">
		        	<div class="air-pie">
		        		<div class="wr-zhibiao-control flex-row zhe">
							<span class="flex-row-item zhibiao-item color-aqi" dn='aqi' ix='0'>AQI</span>
							<span class="flex-row-item zhibiao-item color-pm25" dn='pm25' ix='1'>PM<sub>2.5</sub></span>
							<span class="flex-row-item zhibiao-item color-pm10" dn='pm10' ix='2'>PM<sub>10</sub></span>
							<span class="flex-row-item zhibiao-item color-so2" dn='so2' ix='3'>SO<sub>2</sub></span>
							<span class="flex-row-item zhibiao-item color-no2" dn='no2' ix='4'>NO<sub>2</sub></span>
							<span class="flex-row-item zhibiao-item color-co" dn='co' ix='5'>CO</span>
							<span class="flex-row-item zhibiao-item color-o3" dn='o3' ix='6'>O<sub>3</sub></span>
						</div>
		        	</div>
		        	<div class="wr-chart-item" id="wrchat-onetimeair"></div>
		        </div>
		        <h1 class="h_tit">工业排放量及AQI（月度日均值）</h1>
		        <div class="wr-chat">
		        	<div class="wr-chart-item" id="wrchat-factoryout"></div>
		        </div>
			</div>

			<!-- 目标考核 -->
			<div class="tagContent" id="tagContent2">
				<div class="title_box">
	        		<h1 class="h_tit">空气质量优良率</h1>
			        <div class="order-hd-select">
			          <select class="month-select everymonth-select" id="ylv-month-select"></select>
			        </div>
      			</div>
			    <div class="wr-chat">
			        <div class="left-chart">
			          <div id="chart-1"></div>
			        </div>
			        <div class="right-info">
			          <div id="chart-1-title"></div>
			        </div>
			    </div>
			    <div class="title_box">
			        <h1 class="h_tit">各区PM2.5浓度</h1>
			        <div class="order-hd-select">
			          <select class="month-select" id="month-select"></select>
			        </div>
			    </div>
			    <div class="wr-chat order-bd">
			        <table>
			            <thead class="thead">
			              <tr class="firstRow">
			                <td rowspan="2" colspan="1">区域</td>
			                <td valign="top" rowspan="1" colspan="4">PM2.5（μg/m3）</td>
			              </tr>
			              <tr id="order-month-warp">
			                <td>2016年4月</td>
			                <td>环比</td>
			                <td>同比</td>
			                <td>较2013年全年(目标)</td>
			              </tr>
			            </thead>
			            <tbody id="sorttable"></tbody>
			        </table>  
			    </div>		
			</div>
		</div>
	</div>
	
	<footer id="public_footer">
		<ul>
			<li class="active">
				<a href="index.html">
					<span class="foot_pic air"></span>
					<span>大气环境</span>
				</a>
			</li>
			<li>
				<a href="water-environment.html">
					<span class="foot_pic water"></span>
					<span>水环境</span>
				</a>
			</li>
			<li>
				<a href="voice-environment.html">
					<span class="foot_pic voice"></span>
					<span>声环境</span>
				</a>
			</li>
		</ul>
	</footer>
</body>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/highcharts.js"></script>
<script src="assets/js/touch.min.js"></script>

<script>
function selectTag(showContent,selfObj,catetype){
	
	var tag = document.getElementById("nav_list").getElementsByTagName("li");
	var taglength = tag.length;
	for(i=0; i<taglength; i++){
	  tag[i].className = "";
	}
	selfObj.parentNode.className = "active";
	
	for(i=0; j=document.getElementById("tagContent"+i); i++){
	  j.style.display = "none";
	}
	$('#tagContent .loadding').show();
	setTimeout(function(){
		if(catetype != ''){
			var head = document.getElementsByTagName('head')[0],
				body = document.getElementsByTagName('body')[0];
			if(catetype == 'index' ){
				$("script[src='assets/js/map.js']").remove();
				$("script[src='assets/js/air_quality.js']").remove();
				$("link[href='assets/css/air.css']").remove();
				$("link[href='assets/css/map.css']").remove();
				$("script[src='assets/echart/echarts']").remove();
				$("script[src='assets/echart/echarts.pie.min.js']").remove();
				$("script[src='assets/js/function.js']").remove();
			}else if(catetype == 'air' ){
				$("link[href='assets/css/map.css']").remove();
				$("script[src='assets/js/map.js']").remove();
				$("script[src='assets/echart/echarts.js']").remove();
				var link = document.createElement('link'); 
				    link.href = 'assets/css/air.css';    
				    link.rel = 'stylesheet';    
				    link.type = 'text/css'; 
				head.appendChild(link);  
				var arr = ['assets/echart/echarts.pie.min.js','assets/js/function.js','assets/js/air_quality.js'];
				for(i=0;i<arr.length;i++){
					var script = document.createElement('script');    
				    script.src = arr[i];     
				    script.type = 'text/javascript';  
			   		body.appendChild(script);
				}
			}else if(catetype == 'map' ){
				$("link[href='assets/css/air.css']").remove();
				$("script[src='assets/echart/echarts.pie.min.js']").remove();
				$("script[src='assets/js/air_quality.js']").remove();
				$("script[src='assets/js/function.js']").remove();
				var link = document.createElement('link'); 
				    link.href = 'assets/css/map.css';    
				    link.rel = 'stylesheet';    
				    link.type = 'text/css'; 
				head.appendChild(link);  
				var arr = ['assets/echart/echarts.js','assets/js/map.js'];
				for(i=0;i<arr.length;i++){
					var script = document.createElement('script');    
				    script.src = arr[i];     
				    script.type = 'text/javascript';  
			   		body.appendChild(script);
				}
			}
		}
		document.getElementById(showContent).style.display = "block";
		if(document.getElementById(showContent).style.display == "block"){
			$('#tagContent .loadding').hide();
		}
	},1000);
}

function setHeaderStyle(aqi){
	var infobox={
				'background-color':'rgba(255,255,255,0.5)'
			},
			aqibox={
				color:num2color(parseInt(aqi)),
				'text-shadow':'-1px 1px 0px rgba(0,0,0,0.1)',
				'background-color':'rgba(0,0,0,0.1)'
			},
			djbox={
				color:'#ffffff',
			},
			css={};

	css['background-color']=num2color(parseInt(aqi));
	css['color']='#7A469D';
	css['background-image']='url(./assets/img/bg'+(num2table(parseInt(aqi)).idx+1)+'.png)';

	if(aqi<51){
		aqibox['background-color']='rgba(0,0,0,0.15)';
		infobox['background-color']='rgba(0,0,0,0.15)';
		css['color']='#ffffff';
		css['text-shadow']='-1px 1px 0px rgba(0,0,0,0.1)';
	}else if(aqi>=51&&aqi<101){
		djbox={color:'#7A469D'};
		infobox['background-color']='rgba(0,0,0,0.0)';
	}else if(aqi>=101&&aqi<151){
		djbox={color:'#ffffff'};
		css['color']='#ffffff';
		infobox['background-color']='rgba(0,0,0,0.0)';
		infobox['color']='#eeeeee';
	}else if(aqi>=151&&aqi<201){
		djbox={color:'#ffffff'};
		css['color']='#eeeeee';
		infobox['background-color']='rgba(0,0,0,0.0)';
	}else if(aqi>=201&&aqi<301){
		djbox={color:'#ffffff'};
		css['color']='#eeeeee';
		infobox['background-color']='rgba(0,0,0,0.0)';
	}else if(aqi>=301){
		djbox={color:'#ffffff'};
		css['color']='#eeeeee';
		infobox['background-color']='rgba(0,0,0,0.0)';
	}

	$('.aqi-note').css(djbox);
	$('.aqi-val-warp').css(aqibox);
	$('.infobox').css(infobox);
	$('#realtime-aqi').css(css);
}
	var daily_forecast={};
	var CACHE={
		njaqi:'-'
	};
    var tapidx=0;
	var RequestUrl='http://58.213.141.220:8989/njhbindex';
	// var RequestUrl='.';
	touch.on('#app-back', 'tap', function(ev){
	  //exit app
	});
	
	touch.on('#app-order-link-js', 'tap', function(ev){
	  location.href='order.html#js';
	});
	touch.on('#app-order-link-csj', 'tap', function(ev){
	  location.href='order.html#csj';
	});
	
	touch.on('#app-74order-link-js', 'tap', function(ev){
	  location.href='order2.html#js';
	});
	touch.on('#app-74order-link-all', 'tap', function(ev){
	  location.href='order2.html#all';
	});
	
	touch.on('.aqi-chart-time', 'tap', function(ev){
	  tapidx=ev.target.getAttribute('data-idx');
	  $('.aqi-chart-time').removeClass('active').eq(tapidx).addClass('active');
	  //change chart
	  var cd=AQIChartCache[tapidx];
	  AQIChart(cd.time,cd.aqi,cd.pm,cd.so,cd.no,cd.pm2,cd.co,cd.o);
	});
	
    $(document).on('click','.zb-item',function(){
        var disable=$(this).hasClass('disable');
        if(disable==true){
            $(this).removeClass('disable');
        }else{
            $(this).addClass('disable');
        }
	    var cd=AQIChartCache[tapidx];
	    AQIChart(cd.time,cd.aqi,cd.pm,cd.so,cd.no,cd.pm2,cd.co,cd.o);
    });

	//天气预报初始化
	findWeather(RequestUrl+'/weather');	
	
	//天气预报
    function findWeather(url) {
		getJSONData(url,function(data){
			if(data.Error==null){
				var weather=data.Data;
				daily_forecast=weather.daily_forecast;
				var temp=weather.temperature+'<sub>℃</sub>';
				// $('#rt-aqi-temperature').html();
				var scfix;
				if(weather.wind!='-'&&weather.wind.sc.indexOf('-')>-1){
					scfix='级';
				}else{
					scfix='';	
				}
				$('#rt-aqi-weathernote').html('<p class="pb-weather">'+temp+'  '+weather.weather + '</p>'+'<p class="pb-wind">'+weather.wind.dir +weather.wind.sc+scfix +'</p>');
				$('#rt-aqi-weather').css({
					'background': 'url(./assets/cond_icon/'+(weather.icon==''?'999':weather.icon)+'.png) no-repeat center center',
					'background-size':'cover'
				});			
			}
			callAQIF();
		});	   
    }

	// 实时数据
	getJSONData(RequestUrl+"/data?act=aqin&areacode=2000",function(data){
		if(data.Error==null){
			var aqidata=data.Data;
			setRealtimeAQI(aqidata);
		}else{
			console.log(data.Error);
		}
	});	
	
	var AQIChartCache={};
	AQIChange(RequestUrl+'/data?act=aqih&areacode=2000',0);
	AQIChange(RequestUrl+'/data?act=aqid&areacode=2000',1);
	AQIChange(RequestUrl+'/data?act=aqim_new&areacode=2000',2);
	
	function AQIChange(url,num){
	getJSONData(url,function(data){
		if(data.Error==null){
			var time=[],aqi=[],pm=[],so=[],no=[],pm2=[],co2=[],o=[];
			var haqi=data.Data.reverse();
			var aqi2,pm25,so2,no2,pm10,co,o3;

			haqi.forEach(function(e,i){
			    aqi2=num==2?parseFloat(e.aqi):parseFloat(e.aqi);
				pm25=num==2?parseFloat(e.aqi_pm25):parseFloat(e.pm25);
				so2=num==2?parseFloat(e.aqi_so2):parseFloat(e.so2);
				no2=num==2?parseFloat(e.aqi_no2):parseFloat(e.no2);
				pm10=num==2?parseFloat(e.aqi_pm10):parseFloat(e.pm10);
				co=num==2?parseFloat(e.aqi_co):parseFloat(e.co);
				o3=num==2?parseFloat(e.aqi_o3):parseFloat(e.o3);
				var aqiitem={
					color: num2color(aqi2),
					y: aqi2
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-1.png)'}:null
				}			
				var pmitem={
					color: num2color(pm25),
					y: pm25
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-2.png)'}:null
				}
				var soitem={
					color: num2color(so2),
					y: so2
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-3.png)'}:null
				}	
				var noitem={
					color: num2color(no2),
					y: no2
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-4.png)'}:null
				}
				var pm2item={
					color: num2color(pm10),
					y: pm10
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-5.png)'}:null
				}
				var coitem={
					color: num2color(co),
					y: co
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-6.png)'}:null
				}
				var oitem={
					color: num2color(o3),
					y: o3
					,marker:i==0?{width:15,height:15,symbol:'url(./assets/img/num-7.png)'}:null
				}				
				time.push(e.date);
				aqi.push(aqiitem);
				pm.push(pmitem);
				so.push(soitem);
				no.push(noitem);
				pm2.push(pm2item);
				co2.push(coitem);
				o.push(oitem);
			});
			if (num==0){
			    AQIChart(time,aqi,pm,so,no,pm2,co2,o);
			}
			//缓存
			AQIChartCache[num]={time:time,aqi:aqi,pm:pm,so:so,no:no,pm2:pm2,co:co2,o:o};
		}
	});	
	}

	//生成12个月的下拉
	var currentMonth = (new Date()).pattern("M")-1,
	    currentYear = (new Date()).pattern("yyyy");
	if(currentMonth==0){
		currentMonth=12;
		currentYear-=1;
	}
	currentMonth=currentMonth<10?'0'+currentMonth:currentMonth;
    var monthArray = function (now) {
    var d = new Date(now.replace(/[^\d]/g, "/") + "/1");
    var result = [now];
    for(var i = 0; i < 11; i++) {
        d.setMonth(d.getMonth() - 1);
        var m = d.getMonth() + 1;
        m = m < 10 ? "0" + m : m;
        result.push(d.getFullYear() + "-" + m);
    }
    return result;
    }
     
	var tmpselect=''; 
    monthArray(currentYear+'-'+currentMonth).forEach(function(e,v){
        tmpselect+='<option value="'+e+'">'+e.replace(/-/g,'年')+'月</option>';
	});
	$('#month-select').html(tmpselect);
	// PMSort(RequestUrl+'/data?act=aqiorder&areacode=2000&month=',currentYear+'-'+currentMonth);
	// //月份切换
    $('#month-select').change(function(){
	    // PMSort(RequestUrl+'/data?act=aqiorder&areacode=2000&month=',$(this).val());	
		setSortTable($(this).val());
    })	
	
	var OTModel={
		2000:['市区','市区','nj'],
		2001:['草场门','鼓楼区','glq',[119.995278, 31.758333]],
		2002:['中华门','雨花台区','yhtq',[119.933056, 31.778611]],
		2003:['瑞金路','秦淮区','qhq',[119.961944, 31.808889]],
		2004:['玄武湖','玄武区','xwq',[119.935, 31.703889]],
		2006:['山西路','鼓楼区','glq',[119.904722, 31.910833]],
		2007:['迈皋桥','栖霞区','xxq',[120.039167, 31.763611]],
		2008:['仙林大学城','栖霞区','xxq',[119.455833, 31.4]],
		2009:['奥体中心','建邺区','jyq',[119.474722, 31.400833]],
		2010:['浦口','浦口区','pkq',[119.448056, 31.307778]],
		2013:['高淳淳溪','高淳区','gcq',[118.890583, 31.3294]], //区
		2016:['江宁彩虹桥','江宁区','jnq',[118.831033, 31.928091]],//区
		2022:['六合雄州','六合区','lhq',[118.839798, 32.359663]],//区
		2024:['溧水永阳','溧水区','lsq',[119.019125, 31.648064]],//区
	};
	var OTMTarget={
		nj:{
			target:-13
			,val:0
		}
		,glq:{
			target:-13
			,val:76
		}
		,yhtq:{
			target:-13
			,val:78
		}
		,qhq:{
			target:-13
			,val:79
		}
		,xwq:{
			target:-13
			,val:76
		}
		,xxq:{
			target:-13
			,val:77
		}
		,jyq:{
			target:-13
			,val:81
		}
		,pkq:{
			target:-13
			,val:79
		}
		,gcq:{
			target:-2
			,val:49
		}
		,jnq:{
			target:-4
			,val:63
		}
		,lhq:{
			target:-4
			,val:66
		}
		,lsq:{
			target:-2
			,val:48
		}
	}
	var _OTM_=['gcq','jnq','lhq','lsq'];
	//pm2.5各区排行方法
	function PMSort (url,month){
		var count=4, datas={};
		var _m=month.split('-'),y=_m[0],m=_m[1];
		var cm=month,cmcs=y+'-01',hcmc='2013-'+m,hcmc2='2014-'+m,tb=(y-1)+'-'+m;
		var pm=m-1;
		var py=pm<=0?y-1:y;
		pm=pm<=0?12:pm;
		_pm=pm<10?'0'+pm:pm;
		var pmonth=py+'-'+_pm;
		
		
		function callback(){
			if(count>0) return;
			var __m=m-1+1;
			var tds=$('#order-month-warp').find('td');
			tds.eq(0).html(y+'年'+__m+'月');
			tds.eq(1).html('环比');
			// tds.eq(2).html(y+'年1'+'-'+__m+'月');
			tds.eq(2).html('同比');
			setOrderTable(datas,y);
			// console.log('PMSort',datas);
		}
		function getOrderMonthsData(url,k,y){
			getJSONData(url,function(data){
				if(data.Error==null){
					data.Data.forEach(function(e,i){
						var code=e.code;
						if(OTModel[code]==undefined){
							// console.log(code);
							return;
						} 
						var id=OTModel[code][2];
						if(y==2013){
							if(_OTM_.indexOf(id)>-1) return;
						}else if(y==2014){
							if(_OTM_.indexOf(id)==-1) return;
						}
						if(datas[id]){
							if(datas[id][k]==undefined) datas[id][k]=[];
							datas[id][k].push(parseFloat(e.pm25));
						}else{
							datas[id]={};
							datas[id].name=e.area;
							datas[id][k]=[parseFloat(e.pm25)];
						}
					});
				}else{
					console.log(data.Error);
				}
				count--;
				callback();
			});	
		}
		var url1=url+month,
			url2=url+pmonth,
			url3=RequestUrl+'/data?act=aqiorderbymonth&startmonth='+cmcs+'&endmonth='+month,
			url4=RequestUrl+'/data?act=aqiorderbymonth&startmonth=2013-01&endmonth=2013-12',
			url5=url+hcmc2,
			url6=RequestUrl+'/data?act=aqiorderbymonth&startmonth=2014-01&endmonth=2014-12',
			url7=url+tb;
		
		getOrderMonthsData(url1,'v',2016);
		getOrderMonthsData(url2,'v1',2016);
		getOrderMonthsData(url3,'v2',2016);
		// getOrderMonthsData(url4,'v3',2013);
		// getOrderMonthsData(url5,'v1',2014);
		getOrderMonthsData(url7,'v4',2016);
		getOrderMonthsData(url6,'v3',2014);
	}
	var rand = (function(){
			var seed = (new Date()).getTime()
			function r(){
				seed = (seed*9301+49297)%233280
				return seed/(233280.0)
			}
			return function(number){
				return Math.ceil(r()*number)
			}
	})();
	
	
	
	function setOrderTable(data,y){
		var html='';
		for(var i in data){
			// console.log(data[i]);
			var tds=$('#st-'+i).find('td');
			var v=getAVG(data[i].v),v1=getAVG(data[i].v1),v2=getAVG(data[i].v2),v3=getAVG(data[i].v3),v4=getAVG(data[i].v4);
			tds.eq(1).html(v);
			var g1=getGrowth(v,v1),g2=getGrowth(v,v4),g3=getGrowth(v2,OTMTarget[i].val);
			tds.eq(2).html(g1+'%').css('color',g1<0?'green':'orange');
			tds.eq(3).html(g2+'%').css('color',g2<0?'green':'orange');
			tds.eq(4).html(g3+'%<i class="targetNum">('+OTMTarget[i].target+'%)</i>').css('color',g3<OTMTarget[i].target?'green':'orange');
			// tds.eq(5).html();
		}
		// $('#targetNum').html(y+'年目标'+years[y]+'%。');
	}
	function getAVG(arr){
		if(arr==undefined||arr.length==0) return rand(30)+35;
		var avg=0;
		for(var i=0,l=arr.length;i<l;i++){
			avg=avg+arr[i]-0;
		}
		avg/=i;
		
		return avg.toFixed(2);
	}
	function getGrowth(v1,v2){
		if(v1==''||v2=='') return '';
		return (((v1-v2)/v2)*100).toFixed(2);
	}
	
	function callAQIF(){
		//空气质量预报
		getJSONData(RequestUrl+"/data?act=aqif",function(data){
			var ndata=[];
			if(data.Error==null){
				data.Data.reverse();
				data.Data.forEach(function(e,i){
					var time=e.date,
							notes=e.note,
							first=e.first,
							level=e.level,
							num=note2num(e.note);
					ndata.push({
						aqinum:e.aqi+'-'+e.eaqi,
						aqitime:time,
						aqifirst:first,
						aqinote:notes,
						aqilevel:level
					});
				});
				setAqiTables(ndata);
			}else{
				console.log(data.Error);
			}
		});
	}
			
	
	function getDailyForecast(dfs,i){
		var scfix='',weather_note='';
		var df=dfs[i];
		if(!!df){
			scfix=df.wind.sc.indexOf('-')>-1?'级':'';
			weather_note=df.cond.txt_d+'<br/>'+df.tmp.min+'-'+df.tmp.max+'℃<br/>'+df.wind.dir+df.wind.sc+scfix;
		}
		return weather_note;
	}
	function ConvertToMeetingTimeString(DateObjOrDateString){
		if(typeof DateObjOrDateString == "object"){
			DateObjOrDateString = DateObjOrDateString.Format("yyyy-MM-dd hh:mm");
		}
		var SplitResult = DateObjOrDateString.split(' ');
		var targetDate = new Date(SplitResult[0]); 
		var now = new Date();
		var dd = new Date();
		dd.setDate(dd.getDate()+1);
		var y = dd.getFullYear();
	    var m = dd.getMonth()+1;
	    var d = dd.getDate();
	    if(m<10){
	    	m = '0'+m;
	    }
	    if(d<10){
	    	d = '0'+d;
	    }
	    var tomorrow = y+"-"+m+"-"+d;
	    var now_date = now.pattern("yyyy-MM-dd");
		if(now_date == SplitResult[0]) {
			var week = '今天';
		}else if(SplitResult[0] == tomorrow){
			var week ='明天';
		}else{
			week = targetDate.pattern("MM-dd");
		}
		return  week ;
	}
	//生成空气预报表单
	function setAqiTables(data){
		var strs='',tpl='<tr>'
							+'<td class="date"><span> {time} </span></td>'
							+'<td class="date"><span>{aqilevel}<small>{aqinote}</small></span></td>'
							+'<td><span>{daily_forecast}</span></td>'
							+'<td><span>{aqifirst}</span></td>'
						+'</tr>';
		if(data&&data.length>0){
			data.forEach(function(d,i){
				var _var=num2table(d.aqinum),
						oDate = new Date(d.aqitime.replace(/-/g,'/'));
				var time = ConvertToMeetingTimeString(d.aqitime);
				var str=tpl.replace('{time}',time)
								.replace('{aqilvlnote}',_var.note)
								.replace('{aqinote}',d.aqinote)
								.replace('{aqilevel}',d.aqinum)
								.replace('{aqifirst}',d.aqifirst==null?'无':getAQIItemByStr(d.aqifirst))
								.replace('{daily_forecast}',getDailyForecast(daily_forecast,i));
				
				strs+=str;
			});
		}else{
			strs='<tr><td colspan="4">暂时没有预报信息</td></tr>';
		}
		$('#aqi-tables').html(strs);
	}	
	function getAQIItemByStr(code){
		if(!code) return '-';
		var codeitems={
			'SO':'SO<sub>2</sub>',
			'NO2':'NO<sub>2</sub>',
			'CO':'CO',
			'O3':'O<sub>3</sub>',
			'PM10':'PM<sub>10</sub>',
			'PM2.5':'PM<sub>2.5</sub>'
		};
		var items=[];
		code.split(',').forEach(function(){
			items.push(codeitems[code]);
		});
		return items.join(',');
	}
	function note2num(note){
		var num=0;
		if(note.indexOf('良')>-1){
			num=51
		}else if(note.indexOf('轻度')>-1){
			num=101
		}else if(note.indexOf('中度')>-1){
			num=151
		}else if(note.indexOf('重度')>-1){
			num=201
		}else if(note.indexOf('严重')>-1){
			num=301
		}
		return num
	}	
	
	function num2color(num){
		var num=parseInt(num);
		var color='rgba(0,228,0,1)';
		if(num<=50){
			color='rgba(0,228,0,1)';
		}else if(50<num&&num<=100){
			color='rgba(255,255,0,1)';
		}else if(100<num&&num<=150){
			color='rgba(255,126,0,1)';
		}else if(150<num&&num<=200){
			color='rgba(255,0,0,1)';
		}else if(200<num&&num<=300){
			color='rgba(153,0,76,1)';
		}else if(num>300){
			color='rgba(126,0,35,1)';
		}
		return color
	}
    function num2table(num){
		var num=parseInt(num);
		var idx=0,note='';
		if(num<=50){
			idx=0;
			note='优秀';
		}else if(50<num&&num<=100){
			idx=1;
			note='良好';
		}else if(100<num&&num<=150){
			idx=2;
			note='轻度污染';
		}else if(150<num&&num<=200){
			idx=3;
			note='中度污染';
		}else if(200<num&&num<=300){
			idx=4;
			note='重度污染';
		}else if(num>300){
			idx=5;
			note='严重污染';
		}
		return {idx:idx,note:note}
	}
	// 根据实时数据初始化页面参数
	function setRealtimeAQI(aqidata){
	    aqidata.forEach(function(e,i){
		    $('#rt-aqi-pm25').html(e.pm25);
		    $('#rt-aqi-pm100').html(e.pm10);
		    $('#rt-aqi-no2').html(e.no2);
		    $('#rt-aqi-so2').html(e.so2);
		    $('#rt-aqi-co').html(e.co);
		    $('#rt-aqi-o3').html(e.o3);
			$('#rt-aqi-num').html(e.aqi);
			$('#rt-aqi-lv').html(e.note);
			$('#rt-aqi-first').html(getAQIItemByCode(e.first));
			// $('#realtime-aqi').css({'background-color':num2color(e.aqi),color:num2table(e.aqi).idx==1?'#6F3695':'#ffffff','text-shadow':'none'});
			setHeaderStyle(e.aqi);
			if(e.first==null){
				$('.aqi-note').css('display','none');
			}
		});
	}
	function getAQIItemByCode(code){
		if(!code) return '-';
		var codeitems={
			211:'SO<sub>2</sub>',
			213:'NO<sub>2</sub>',
			215:'CO',
			218:'O<sub>3</sub>',
			220:'PM<sub>10</sub>',
			221:'PM<sub>2.5</sub>',
			2151:'CO'
		};
		var items=[];
		code.split(',').forEach(function(){
			items.push(codeitems[code]);
		});
		return items.join(',');
	}
	// 生成折线图
	function AQIChart(time,aqi,pm,so,no,pm2,co,o){
		var chart1 = new Highcharts.Chart({
         chart: {
            renderTo: 'aqi-chart'
         },
		// $('#aqi-chart').highcharts({
    		credits:{
    			enabled:false
    		},
        title: {
            text: '',
            x: -20 //center
        },
        subtitle: {
            text: '指数',
			align: 'left'			
        },
        xAxis: {
            categories: time,
            gridLineColor:'#EEEEEE',
            gridLineWidth: 1,
            tickLength:3,
            labels:{
            	enabled:true,
            	style:{
            		color: '#A7A7A7',
					fontWeight: 'normal',
				    fontSize:'8px'
            	}
            }
        },
        yAxis: {
            title: {
                text: ''
            },
            gridLineWidth: 0,
            labels:{
            	style:{
            		color: '#B7B7B7',
					fontWeight: 'normal',
					fontSize:'8px'
            	}
            }
        },
        tooltip: {
            // valueSuffix: 'ug/m³'
            formatter:function(){
            	var suffix='',name=this.series.name;
            	return '<small>'+this.x+'</small><br/>'+name+': '+this.y+suffix;
            }
        },
        legend: {
            layout: 'horizontal',
            align: 'right',
            verticalAlign: 'top',
            borderWidth: 0,
            lineHeight:12,
            margin:0,
            padding:0,
            itemMarginBottom:8,
            itemStyle:{
            	fontWeight:"normal",
            	fontSize:'8px'
            }
        },
        plotOptions: {
            series: {
                marker: {
                    fillColor: null,
                    lineWidth: 1,
                    radius: 2,
                    lineColor: null // inherit from series
                    ,states:{
                    	hover:{
                    		enabled:true,
                    		fillColor: null,
                    		lineColor: null
                    	},
                    	select:{
                    		enabled:true,
                    		fillColor: null,
                    		lineColor: null
                    	}
                    }
                }
            }
        },
        series: [{
            name: 'AQI',
            data: aqi,
            color:'#FE9A01'
        },{
            name: 'PM2.5',
            data: pm,
            color:'#00E3D8',
			visible:false
        }, {
            name: 'so2',
            data: so,
            color:'#e4b503',
			visible:false
        }, {
            name: 'no2',
            data: no,
            color:'#688ff4',
			visible:false
        }, {
            name: 'pm10',
            data: pm2,
            color:'#23ae39',
			visible:false
        }, {
            name: 'co',
            data: co,
            color:'#e16f6e',
			visible:false
        }, {
            name: 'o3',
            data: o,
            color:'#01b3d9',
			visible:false
        }]
    });
	drawMyLegend(chart1);

	}
	
/**
 *遍历自定义折线图图标状态
 */ 
function drawMyLegend(chart) {
    $('.zb-item').each(function(i) {
        //if (chart.series[i + 2] == undefined) return;
        var disable = $(this).hasClass('disable');
        if (disable == false) {
            chart.series[i].show();
        } else {
            chart.series[i].hide();
        }
    });
}	
	
    
		
	
	//省内及长三角排名方法
    function get_citys_order(ele){
	var jsorder=[],csjorder=[],jstop,csjtop;
	var JSCitys  = '盐城市,南通市,扬州市,泰州市,镇江市,宿迁市,苏州市,淮安市,常州市,连云港市,无锡市,南京市,徐州市';
	var CSJCitys = '拉萨,海口,昆明,惠州,厦门,舟山,张家口,福州,深圳,中山,珠海,大连,台州,肇庆,贵阳,南昌,佛山,东莞,广州,丽水,承德,南宁,江门,盐城,衢州,西宁,温州,合肥,上海,淮安,宁波,扬州,泰州,宿迁 ,连云港,兰州,镇江,青岛,杭州,嘉兴,湖州,绍兴,南通,呼和浩特,苏州,无锡,南京,北京,金华,长沙,常州,秦皇岛,廊坊,重庆,徐州,西安,长春,乌鲁木齐,沧州,成都,武汉,天津,太原 ,唐山,银川,哈尔滨,济南,沈阳,衡水,郑州,邯郸,石家庄,邢台,保定';
	getJSONData(RequestUrl+'/map',function(data){
		data.Data.forEach(function(e){
			if(JSCitys.indexOf(e.name)>-1&&e.name!='南京市'){
				jsorder.push({name:e.name,aqinum:e.aqi});
			}
			if(CSJCitys.indexOf(RMS(e.name))>-1&&e.name!='南京市'){
				csjorder.push({name:e.name,aqinum:e.aqi});
			}
		});
		getJSONData(RequestUrl+'/data?act=aqin&areacode=2000',function(obj){
			var aqi=0;
			var hisdata = obj.Data;
			// for(var i in hisdata){
			// 	if(hisdata[i].name=='市区'){
					jsorder.push({name:'南京市',aqinum:hisdata[0].aqi});
					csjorder.push({name:'南京市',aqinum:hisdata[0].aqi});
			// 	}
			// }
			jsorder=jsorder.sort(function(a,b){
				var i=-1,an=parseInt(a.aqinum),bn=parseInt(b.aqinum);
				if(an==bn){
					if(RMS(a.name)=='南京市') i=-1;
					if(RMS(b.name)=='南京市') i=1;
				}else{
					i=an-bn;
				}
				return i
			});
			// csjorder=[].concat(csjorder,jsorder);
			csjorder.sort(function(a,b){
				var i=-1,an=parseInt(a.aqinum),bn=parseInt(b.aqinum);
				if(an==bn){
					if(RMS(a.name)=='南京市') i=-1;
					if(RMS(b.name)=='南京市') i=1;
				}else{
					i=an-bn;
				}
				return i
			});
			$.each(jsorder, function(i,e) {
				if(e.name=='南京市'){
					jstop = i+1;
					aqi=e.aqinum;
				}
			});
			$.each(csjorder, function(i,e) {
				if(e.name=='南京市'){
					csjtop = i+1;
					aqi=e.aqinum;
				}
			});
			$('#js-order-val').html(jstop);
			$('#csj-order-val').addClass('waring').html(csjtop);
		});
	});
    }
	get_citys_order();
	
	//获取74城市省内及长三角排名
	function citys74(_month){
		var year,month;
		if(_month==undefined){
			var date=new Date(),year=date.getFullYear(),month=date.getMonth()+1;
			if(month==0){
				year=year-1;
				month=12;
			}
			_month=(month<=9?'0'+month:month);
			_month=year+''+_month;
		}else{
			year=_month.substr(0,4);
			month=_month.substr(4)-0;
		}
		/*getJSONData('./xlsx?act=order&month='+_month,function(data){
			if(data.Error==null){
				var all=data.Data.all,js=data.Data.js;
				if(all==undefined&&js==undefined){
					month=month-1;
					if(month==0){
						year=year-1;
						month=12;
					}
					_month=(month<=9?'0'+month:month);
					citys74(year+''+_month);
				}else{
					$('#citys74-js-order-val').html(js);
					$('#citys74-all-order-val').addClass('waring').html(all);
				}
			}
		});*/
		$('#month-74citys-select').val(_month);
	}
	
	generateMonth();
	citys74();
	
	function citys74chart(time,js,all){
		$('#citys74-chart').highcharts({
			credits:{
				enabled:false
			},
			title: {
				text: '',
				x: -20 //center
			},
			subtitle: {
				text: '排名',
				align: 'left'			
			},
			xAxis: {
				categories: time,
				gridLineColor:'#EEEEEE',
				gridLineWidth: 1,
				tickLength:3,
				labels:{
					enabled:true,
					style:{
						color: '#A7A7A7',
						fontWeight: 'normal',
						fontSize:'8px'
					}
				}
			},
			yAxis: {
				title: {
					text: ''
				},
				gridLineWidth: 0,
				labels:{
					style:{
						color: '#B7B7B7',
						fontWeight: 'normal',
						fontSize:'8px'
					}
				}
			},
			tooltip: {
				// valueSuffix: 'ug/m³'
				formatter:function(){
					var suffix='',name=this.series.name;
					return '<small>'+this.x+'</small><br/>'+name+': '+this.y+suffix;
				}
			},
			legend: {
				layout: 'horizontal',
				align: 'right',
				verticalAlign: 'top',
				borderWidth: 0,
				lineHeight:12,
				margin:0,
				padding:0,
				itemMarginBottom:8,
				itemStyle:{
					fontWeight:"normal",
					fontSize:'8px'
				}
			},
			plotOptions: {
				series: {
					marker: {
						fillColor: null,
						lineWidth: 1,
						radius: 3.5,
						lineColor: null // inherit from series
						,states:{
							hover:{
								enabled:true,
								fillColor: null,
								lineColor: null
							},
							select:{
								enabled:true,
								fillColor: null,
								lineColor: null
							}
						}
					}
				}
			},
			series: [
				{
					name: '省内南京排名',
					data: js,
					color:'#FE9A01'
				},
				{
					name: '74城市南京排名',
					data: all,
					color:'#00E3D8'
				}
			]
		});
	}
	
	/*getJSONData('./xlsx?act=chart',function(data){
		if(data.Error==null){
			var time=[],js=[],all=[];
			data.Data.forEach(function(e){
				time.push(e.date);
				js.push(e.js);
				all.push(e.all);
			});
			citys74chart(time,js,all);
		}
	});*/
	
	function generateMonth(){
		//生成12个月的下拉
		var currentMonth = (new Date()).pattern("MM"),
			currentYear = (new Date()).pattern("yyyy");
		var monthArray = function (now) {
			var d = new Date(now.replace(/[^\d]/g, "/") + "/1");
			var result = [];
			for(var i = 0; i < 15; i++) {
				d.setMonth(d.getMonth() - 1);
				var m = d.getMonth() + 1;
				m = m <=9 ? "0" + m : m;
				result.push({v:d.getFullYear()+''+m,n:d.getFullYear()+'年'+m+'月'});
			}
			return result;
		}
		
		var tmpselect=''; 
		monthArray(currentYear+'-'+currentMonth).forEach(function(e,v){
			tmpselect+='<option value="'+e.v+'">'+e.n+'</option>';
		});
		$('#month-74citys-select').html(tmpselect);
		//月份切换
		$('#month-74citys-select').change(function(){
			citys74($(this).val());	
		});
	}
	
	
    function RMS(s){
      return s.replace('市','');
    }
	
	//通用方法
	function getJSONData(url,callback){
      $.ajax({
          type: "get",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          url: url,  //这里是网址
          success: function (json) {
              callback(json)
          },
          timeout: 60000,
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              console.error(url,textStatus+": "+errorThrown);
          }
      });
    }
	
	var areas={
			1:["南京开发区","2008","仙林大学城",-13,1],
			2:["栖霞区","2008,2007","仙林大学城,迈皋桥",-13,2],
			3:["建邺区","2009","奥体中心",-13,3],
			4:["高新开发区","2010","浦口",-13,4],
			5:["浦口区","2010","浦口",-13,5],
			6:["玄武区","2004","玄武湖",-13,6],
			7:["鼓楼区","2001,2006","草场门，山西路",-13,7],
			8:["秦淮区","2003","瑞金路",-13,8],
			9:["六合区","2022","雄州",-4,9],
			10:["江宁开发区","2018","将军大道",-13,10],
			11:["雨花台区","2002","中华门",-13,11],
			12:["南京化工园","2011","化工园",-13,12],
			13:["高淳区","2013","淳溪",-2,13],
			14:["江宁区","2016","彩虹桥",-4,14],
			15:["溧水区","2024","永阳",-2,15],
			16:["全市","2000","全市",-13,16]
		},areas2014={
			9:'*',
			13:'*',
			14:'*',
			15:'*',
		};
	// getJSONData(RequestUrl+'/data?act=areainfo',function(data){
	// 	var trs=[];
	// 	if(data.Error==null){
	// 		data.Data.forEach(function(e,i){
	// 			areas[e.id][0]=e.name;
	// 			areas[e.id][1]=e.codes;
	// 			areas[e.id][2]=e.areas;
	// 			areas[e.id][3]=e.target;
	// 			areas[e.id][4]=e.index;
	// 			trs.push('<tr id="st-'+e.id+'"><td>'+e.name+(areas2014[e.id]!=undefined?'*':'')+'</td><td></td><td></td><td></td><td></td></tr>');
	// 		});
	// 	}
	// 	$('#sorttable').html(trs.join(''));
	// 	setSortTable(currentYear+'-'+currentMonth);
	// });
	function setSortTable(month){
		var qstr=month.split('-');
		var curmstr=qstr[0]+'年'+qstr[1]+'月';
		$('#order-month-warp').find('td').eq(0).html(curmstr);
		getJSONData(RequestUrl+'/data?act=areamonth&month='+month,function(data){
			if(data.Error==null){
				data.Data.forEach(function(e){
					var tds=$('#st-'+e.areaid).find('td')
						,g1=getGrowth(e.value,e.hbrate)
						,g2=getGrowth(e.value,e.tbrate);
					tds.eq(1).html(e.value);
					tds.eq(2).html(g1+'%').css('color',g1<0?'green':'orange');
					tds.eq(3).html(g2+'%').css('color',g2<0?'green':'orange');
				});
			}
		});
		getJSONData(RequestUrl+'/data?act=areayear&year='+qstr[0],function(data){
			if(data.Error==null){
				data.Data.forEach(function(e){
					var pm25,jzpm25,id=e.areaid;
					if(parseInt(qstr[0])==2016){
						if(e.monthtype==200+parseInt(qstr[1])){
							pm25=e.pm25;
							jzpm25=e.jzpm25;
						}
					}else{
						pm25=e.pm25;
						jzpm25=e.jzpm25;
					}
					if(pm25!=undefined&&jzpm25!=undefined){
						var g3=getGrowth(pm25,jzpm25);
						$('#st-'+id).find('td').eq(4).html(g3+'%<i class="targetNum">('+areas[id][3]+'%)</i>').css('color',g3<areas[id][3]?'green':'orange');
					}
				});
			}
		});
	}
	
</script>

<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan style='display:none;' id='cnzz_stat_icon_1259663983'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1259663983' type='text/javascript'%3E%3C/script%3E"));</script>
</html>